#ifndef _PROGRESBAR_H
#define _PROGRESBAR_H

///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		11/07/2014												 //
//	Purpose:	Define a progress bar ui element. Progress bars should	 //
//				show a visual representation of a percentage			 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "UiElement.h"
#include <string>
using namespace std;

// Provides a visual indicator for a percentage
class ProgresBar : public UiElement
{
	// the value that represents the numerator in the percentage calculation
	float value = 0.f;
	// the value that represents the denominator in the percentage calculation
	float maximum = 100.f;

	// the forground color of the progress bar
	Vector4 front_color = vector_4::white;
	// the background color of the progress bar
	Vector4 back_color = vector_4::gray;

	// text to display next to the progress bar
	string text;

public:
	ProgresBar(void);
	virtual ~ProgresBar(void);

	virtual void Update(float dt) override;

	virtual void Draw(void) override;

	/////////////////////<mutators/accessors>//////////////////////////////////////////

	// set the text to display next to the progress bar
	void setText(const char* value) { text = value; }

	// get text to display next to the progress bar
	string getText(void) const { return text; }
	
	// set the width of this element
	void setWidth(int value) { clientRect.setWidth((float)value); }
	// set the height of this element
	void setHeight(int value) { clientRect.setHeight((float)value); }

	// computes how 'full' the bar should be, based on 'value' and maximum
	float getPercentage(void) const { return value / maximum; }

	// get the value that represents the numerator in the percentage calculation
	float getValue(void) const { return value; }

	// get the value that represents the numerator in the percentage calculation
	void setValue(float value) { this->value = value; }

	// get value that represents the denominator in the percentage calculation
	float getMaximum(void) const { return maximum; }

	// set the value that represents the denominator in the percentage calculation
	void setMaximum(float value) { maximum = value; }

	// set the forground color of the progress bar
	void setForgroundColor(Vector4& value) { front_color = value; }

	// set the background color of the progress bar
	void setBackgroundColor(Vector4& value) { back_color = value; }

	// get the forground color of the progress bar
	Vector4 getForgroundColor(void) const { return front_color; }

	// get the background color of the progress bar
	Vector4 getBackgroundColor(void) const { return back_color; }
};

#endif